//
//  POSListCell.m
//  NewPro
//
//  Created by 何荧红 on 2018/10/9.
//  Copyright © 2018 何荧红. All rights reserved.
//

#import "POSListCell.h"

@interface POSListCell ()
@property (nonatomic, assign) BOOL posstatus;//是否能展开

@property (nonatomic, strong) UILabel *number;//sn号
@property (nonatomic, strong) UILabel *cashstatus;//返现时间
@property (nonatomic, strong) UILabel *vidtime;//有效期
@property (nonatomic, strong) UILabel *findlab;//查看lab
@property (nonatomic, strong) UIButton *findbtn;//查看button
@property (nonatomic, strong) UIImageView *searimg;//适配的图片

@property (nonatomic, strong) UIView *footView;
@property (nonatomic, strong) UILabel *lilv;
@property (nonatomic, strong) UILabel *phone;
@property (nonatomic, strong) UILabel *name;
@property (nonatomic, strong) UILabel *shopnumber;
@property (nonatomic, strong) UILabel *subshopnum;

@property (nonatomic, assign) BOOL cellpush;
@property (nonatomic, assign) BOOL CellClik;
@end

@implementation POSListCell
- (void)setIndexarr:(NSMutableArray *)indexarr{
    _indexarr = indexarr;
    if (_indexarr.count > 0) {
        [self CleanSelfWith:self.indexarr];
    }
}
- (void)setDmondel:(PostCanDetailModel *)Dmondel{
    _Dmondel = Dmondel;
    if (_Dmondel) {
        if (_typeV == 7 || _typeV == 9) {
            self.number.text = _Dmondel.sn;
            self.cashstatus.text = _Dmondel.remainingDay;
            if ([_Dmondel.remainingDay integerValue] <= 10) {
                self.cashstatus.textColor = [UIColor colorWithHexString:@"FF2F2F"];
            }else{
                self.cashstatus.textColor = [UIColor colorWithHexString:@"666666"];
            }
            self.CellClik = _Dmondel.isClik;
            if (_Dmondel.isClik) {
                self.searimg.image = [UIImage imageNamed:@"SN已选择"];
            }else{
                self.searimg.image = [UIImage imageNamed:@"SN未选择"];
            }
        }
        if (_typeV == 8) {
            self.number.text = _Dmondel.sn;
            self.cashstatus.text = _Dmondel.remainingDay;
            if ([_Dmondel.remainingDay integerValue] <= 10) {
                self.cashstatus.textColor = [UIColor colorWithHexString:@"FF2F2F"];
            }else{
                self.cashstatus.textColor = [UIColor colorWithHexString:@"666666"];
            }
            self.vidtime.text = @"待确认";
            self.vidtime.textColor = [UIColor colorWithHexString:@"FFA02F"];
        }
        
    }
}

- (void)setHDmodel:(PostHisDetailModel *)HDmodel{
    _HDmodel = HDmodel;
    if (_HDmodel) {
        self.number.text = _HDmodel.posSn;
        self.cashstatus.text = _HDmodel.remainingDay;
        if ([_HDmodel.remainingDay integerValue] <= 10) {
            self.cashstatus.textColor = [UIColor colorWithHexString:@"FF2F2F"];
        }else{
            self.cashstatus.textColor = [UIColor colorWithHexString:@"666666"];
        }
        if (_typeV == 10) {
            if ([_HDmodel.status isEqualToString:@"1"]) {
                self.vidtime.text = @"已回拨";
                self.vidtime.textColor = [UIColor colorWithHexString:@"666666"];
            }else if ([_HDmodel.status isEqualToString:@"2"]){
                self.vidtime.text = @"被拒绝";
                self.vidtime.textColor = [UIColor colorWithHexString:@"FF2F2F"];
            }
        }else if (_typeV == 11){
            if ([_HDmodel.status isEqualToString:@"1"]) {
                self.vidtime.text = @"已接受";
                self.vidtime.textColor = [UIColor colorWithHexString:@"666666"];
            }else if ([_HDmodel.status isEqualToString:@"2"]){
                self.vidtime.text = @"已拒绝";
                self.vidtime.textColor = [UIColor colorWithHexString:@"FF2F2F"];
            }
        }
    }
}
- (void)setModel:(PostlistModel *)model{
    _model = model;
    if (_model) {
        self.number.text = _model.sn;
        self.cashstatus.text = [NSString stringWithFormat:@"0-%@",_model.backAmount];
        if ([_model.remainingDay integerValue] <= 10) {
            self.vidtime.textColor = [UIColor colorWithHexString:@"FF2F2F"];
        }else{
            self.vidtime.textColor = [UIColor colorWithHexString:@"666666"];
        }
        self.vidtime.text = _model.remainingDay;
        if (_model.isClik) {
            self.searimg.image = [UIImage imageNamed:@"SN已选择"];
        }else{
            self.searimg.image = [UIImage imageNamed:@"SN未选择"];
        }
        if ([_model.type isEqualToString:@"0"]) {
            self.backgroundColor = [UIColor whiteColor];
            self.findlab.hidden = NO;
            self.findbtn.hidden = NO;
        }
        if ([_model.type isEqualToString:@"1"]) {
            self.backgroundColor = [UIColor colorWithHexString:@"C7EDFF"];
            self.findlab.hidden = YES;
            self.findbtn.hidden = YES;
        }
    }
}
- (void)setRmodel:(PostlistReviewModel *)Rmodel{
    _Rmodel = Rmodel;
    if (_Rmodel) {
        self.number.text = _Rmodel.sn;
        self.cashstatus.text = [NSString stringWithFormat:@"%@%%",_Rmodel.rate];
    }
}
- (void)setOmodel:(PostlistOpenModel *)Omodel{
    _Omodel = Omodel;
    if (_Omodel) {
        self.number.text = _Omodel.sn;
        if ([_Omodel.remainingDay integerValue] <= 10) {
            self.cashstatus.textColor = [UIColor colorWithHexString:@"FF2F2F"];
        }else{
            self.cashstatus.textColor = [UIColor colorWithHexString:@"666666"];
        }
        self.cashstatus.text = _Omodel.remainingDay;
        self.name.text = [NSString stringWithFormat:@"姓名：%@",_Omodel.merchantName];
        self.lilv.text = [NSString stringWithFormat:@"费率%@%%",_Omodel.rate];
        self.phone.text = [NSString stringWithFormat:@"电话：%@",_Omodel.merchantPhone];
        self.shopnumber.text = _Omodel.merchantNo;
        self.cellpush = _Omodel.isClik;
        if (_Omodel.isClik) {
            self.searimg.image = [UIImage imageNamed:@"上拉按钮"];
        }else{
            self.searimg.image = [UIImage imageNamed:@"下拉按钮"];
        }
        if ([_Omodel.type isEqualToString:@"0"]) {
            self.backgroundColor = [UIColor whiteColor];
            self.findlab.hidden = NO;
            self.findbtn.hidden = NO;
        }
        if ([_Omodel.type isEqualToString:@"1"]) {
            self.backgroundColor = [UIColor colorWithHexString:@"C7EDFF"];
            self.findlab.hidden = YES;
            self.findbtn.hidden = YES;
        }
    }
}
- (void)setUpmodel:(PostlistUpModel *)Upmodel{
    _Upmodel = Upmodel;
    if (_Upmodel) {
        self.number.text = _Upmodel.sn;
        if ([_Upmodel.sign isEqualToString:@"1"]) {
            self.cashstatus.text = @"已返";
        }else if ([_Upmodel.sign isEqualToString:@"0"]){
            self.cashstatus.text = @"冻结";
        }
        self.name.text = [NSString stringWithFormat:@"姓名：%@",_Upmodel.merchantName];
        self.lilv.text = [NSString stringWithFormat:@"费率%@%%",_Upmodel.rate];
        self.phone.text = [NSString stringWithFormat:@"电话：%@",_Upmodel.merchantPhone];
        self.shopnumber.text = _Upmodel.merchantNo;
        self.cellpush = _Upmodel.isClik;
        if (_Upmodel.isClik) {
            self.searimg.image = [UIImage imageNamed:@"上拉按钮"];
        }else{
            self.searimg.image = [UIImage imageNamed:@"下拉按钮"];
        }
    }
}
- (void)setCellpush:(BOOL)cellpush{
    _cellpush = cellpush;
    if (_cellpush) {
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 40);
        self.footView.frame = CGRectMake(0, 20, SCREEN_WIDTH, 20);
        self.footView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.58];
        self.name.hidden = NO;
        self.lilv.hidden = NO;
        self.phone.hidden = NO;
        self.shopnumber.hidden = NO;
        self.subshopnum.hidden = NO;
    }else{
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 20);
        self.footView.frame = CGRectMake(0, 19, SCREEN_WIDTH, 1);
        self.footView.backgroundColor = [UIColor colorWithHexString:@"F4F4F4"];
        self.name.hidden = YES;
        self.lilv.hidden = YES;
        self.phone.hidden = YES;
        self.shopnumber.hidden = YES;
        self.subshopnum.hidden = YES;
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 20);
        [self CleanDefaultView];
    }
    return self;
}
- (void)CleanDefaultView{
    self.title = [[UILabel alloc]init];
    self.title.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:10];
    self.title.textColor = [UIColor colorWithHexString:@"666666"];
    [self addSubview:self.title];
    self.number = [[UILabel alloc]init];
    self.number.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:10];
    self.number.textColor = [UIColor colorWithHexString:@"666666"];
    [self addSubview:self.number];
    self.cashstatus = [[UILabel alloc]init];
    self.cashstatus.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:10];
    self.cashstatus.textColor = [UIColor colorWithHexString:@"333333"];
    [self addSubview:self.cashstatus];
    self.vidtime = [[UILabel alloc]init];
    self.vidtime.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:10];
    self.vidtime.textColor = [UIColor colorWithHexString:@"333333"];
    [self addSubview:self.vidtime];
    self.findlab = [[UILabel alloc]init];
    self.findlab.textColor = [UIColor colorWithHexString:@"0CA6F0"];
    self.findlab.textAlignment = NSTextAlignmentCenter;
    self.findlab.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:8];
    self.findlab.layer.masksToBounds = YES;
    self.findlab.layer.cornerRadius = 2;
    self.findlab.layer.borderWidth = 0.5;
    self.findlab.layer.borderColor = [UIColor colorWithHexString:@"0CA6F0"].CGColor;
    self.findlab.text = @"查看";
    [self addSubview:self.findlab];
    self.findbtn = [[UIButton alloc]init];
    [self.findbtn addTarget:self action:@selector(findtouch) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.findbtn];
    self.searimg = [[UIImageView alloc]init];
    [self addSubview:self.searimg];
    self.footView = [[UIView alloc]initWithFrame:CGRectMake(0, 19, SCREEN_WIDTH, 1)];
    self.footView.backgroundColor = [UIColor colorWithHexString:@"F4F4F4"];
    [self addSubview:self.footView];
    
    self.name = [[UILabel alloc]init];
    self.name.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
    self.name.textColor = [UIColor colorWithHexString:@"ffffff"];
    [self.footView addSubview:self.name];
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.footView.mas_centerY);
        make.left.equalTo(self.footView.mas_left).offset(8);
    }];
    
    self.phone = [[UILabel alloc]init];
    self.phone.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
    self.phone.textColor = [UIColor colorWithHexString:@"ffffff"];
    [self.footView addSubview:self.phone];
    [self.phone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.footView.mas_centerY);
        make.left.equalTo(self.footView.mas_left).offset(88);
    }];
    
    self.lilv = [[UILabel alloc]init];
    self.lilv.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
    self.lilv.textColor = [UIColor colorWithHexString:@"ffffff"];
    [self.footView addSubview:self.lilv];
    [self.lilv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.footView.mas_centerY);
        make.left.equalTo(self.footView.mas_centerX);
    }];
    
    self.subshopnum = [[UILabel alloc]init];
    _subshopnum.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
    _subshopnum.textColor = [UIColor colorWithHexString:@"ffffff"];
    _subshopnum.text = @"商编：";
    [self.footView addSubview:_subshopnum];
    [_subshopnum mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.footView.mas_centerY);
        make.left.equalTo(self.footView.mas_centerX).offset(70);
    }];
    
    self.shopnumber = [[UILabel alloc]init];
    self.shopnumber.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
    self.shopnumber.textColor = [UIColor colorWithHexString:@"ffffff"];
    self.shopnumber.userInteractionEnabled = YES;
    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPre:)];
    [self.shopnumber addGestureRecognizer:longPress];
    [self.footView addSubview:self.shopnumber];
    [self.shopnumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.footView.mas_centerY);
        make.left.equalTo(self.subshopnum.mas_right);
        make.height.mas_equalTo(20);
    }];
}
- (void)findtouch{
    if (self.CellFindBlock) self.CellFindBlock();
}
// 使label能够成为响应事件，为了能接收到事件（能成为第一响应者）
- (BOOL)canBecomeFirstResponder{
    return YES;
}
// 可以控制响应的方法
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender{
    return (action == @selector(copy:));
}
//针对响应方法的实现，最主要的复制的两句代码
- (void)copy:(id)sender{
    //UIPasteboard：该类支持写入和读取数据，类似剪贴板
    UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
    pasteBoard.string = self.shopnumber.text;
}
// 处理长按事件
- (void)longPre:(UILongPressGestureRecognizer *)recognizer{
    [self becomeFirstResponder];
    // 用于UIMenuController显示，缺一不可
    //UIMenuController：可以通过这个类实现点击内容，或者长按内容时展示出复制等选择的项，每个选项都是一个UIMenuItem对象
    [[UIMenuController sharedMenuController] setTargetRect:self.shopnumber.frame inView:self.shopnumber.superview];
    [[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
}
- (void)CleanSelfWith:(NSMutableArray *)arr{
    self.name.hidden = YES;
    self.lilv.hidden = YES;
    self.phone.hidden = YES;
    self.shopnumber.hidden = YES;
    self.subshopnum.hidden = YES;
    self.findlab.hidden = YES;
    self.findbtn.hidden = YES;
    if (_typeV == 0 && arr.count == 9) {//0、未激活
        self.posstatus = NO;
        self.number.hidden = NO;
        self.cashstatus.hidden = NO;
        self.vidtime.hidden = NO;
        self.searimg.hidden = NO;
        self.findlab.hidden = NO;
        self.findbtn.hidden = NO;
        for (UIView *sub in arr) {
            if ([sub isKindOfClass:[UILabel class]]) {
                UILabel *sublab = (UILabel *)sub;
                if ([sublab.text isEqualToString:@"序号"]) {
                    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sublab.centerX);
                        make.height.mas_equalTo(20);
                    }];
                }
                if ([sublab.text isEqualToString:@"终端编号（SN）"]) {
                    [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sublab.frame.origin.x);
                        make.height.mas_equalTo(20);
                    }];
                }
                if ([sublab.text isEqualToString:@"返现范围"]) {
                    [self.cashstatus mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.mas_left).offset(sublab.center.x);
                    }];
                }
                if ([sublab.text isEqualToString:@"有效期"]) {
                    [self.vidtime mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.mas_left).offset(sublab.center.x);
                    }];
                    [self.findlab mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(CGRectGetMaxX(sublab.frame) - 5);
                        make.height.mas_equalTo(10);
                        make.width.mas_equalTo(20);
                    }];
                    [self.findbtn mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.findlab.mas_centerX);
                        make.height.mas_equalTo(20);
                        make.width.mas_equalTo(40);
                    }];
                }
            }
            if ([sub isKindOfClass:[UIButton class]]) {
                UIButton *subbtn = (UIButton *)sub;
                if ([subbtn.titleLabel.text isEqualToString:@"批量"]) {
                    [self.searimg mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.height.mas_equalTo(14);
                        make.width.mas_equalTo(14);
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.mas_left).offset(subbtn.center.x);
                    }];
                }
            }
        }
    }
    if ((_typeV == 1 || _typeV == 2)&& arr.count == 3) {//1、审核中或者审核失败
        self.posstatus = NO;
        self.number.hidden = NO;
        self.cashstatus.hidden = NO;
        self.vidtime.hidden = YES;
        self.searimg.hidden = YES;
        for (UILabel *sub in arr) {
            if ([sub.text isEqualToString:@"序号"]) {
                [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.equalTo(self.mas_centerY);
                    make.left.equalTo(self.mas_left).offset(sub.centerX);
                    make.height.mas_equalTo(20);
                }];
            }
            if ([sub.text isEqualToString:@"终端编号（SN）"]) {
                [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.left.equalTo(self.mas_left).offset(sub.frame.origin.x);
                    make.height.mas_equalTo(20);
                }];
            }
            if ([sub.text isEqualToString:@"费率"]) {
                [self.cashstatus mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.centerX.equalTo(self.mas_left).offset(sub.center.x);
                }];
            }
        }
    }
    if (_typeV == 3 && arr.count == 6) {//2、已开通或者已激活
        self.name.hidden = NO;
        self.lilv.hidden = NO;
        self.phone.hidden = NO;
        self.shopnumber.hidden = NO;
        self.subshopnum.hidden = NO;
        self.posstatus = YES;
        self.number.hidden = NO;
        self.cashstatus.hidden = NO;
        self.vidtime.hidden = YES;
        self.searimg.hidden = NO;
        self.findlab.hidden = NO;
        self.findbtn.hidden = NO;
        for (UIView *sub in arr) {
            if ([sub isKindOfClass:[UILabel class]]) {
                UILabel *sublab = (UILabel *)sub;
                if ([sublab.text isEqualToString:@"序号"]) {
                    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.top.equalTo(self.mas_top).offset(6);
                        make.left.equalTo(self.mas_left).offset(sub.centerX);
                        make.height.mas_equalTo(8);
                    }];
                }
                if ([sublab.text isEqualToString:@"终端编号（SN）"]) {
                    [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sublab.frame.origin.x);
                        make.height.mas_equalTo(20);
                    }];
                }
                if ([sublab.text isEqualToString:@"查询"]) {
                    [self.searimg mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.height.mas_equalTo(5);
                        make.width.mas_equalTo(9);
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.mas_left).offset(sub.center.x);
                    }];
                }
                if ([sublab.text isEqualToString:@"有效期"]) {
                    [self.cashstatus mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.mas_left).offset(sublab.center.x);
                    }];
                    [self.findlab mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(CGRectGetMaxX(sublab.frame) - 5);
                        make.height.mas_equalTo(10);
                        make.width.mas_equalTo(20);
                    }];
                    [self.findbtn mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.findlab.mas_centerX);
                        make.height.mas_equalTo(20);
                        make.width.mas_equalTo(40);
                    }];
                }
            }
        }
    }
    if ( _typeV == 4 && arr.count == 3) {
        self.name.hidden = NO;
        self.lilv.hidden = NO;
        self.phone.hidden = NO;
        self.shopnumber.hidden = NO;
        self.subshopnum.hidden = NO;
        self.posstatus = YES;
        self.number.hidden = NO;
        self.cashstatus.hidden = YES;
        self.vidtime.hidden = YES;
        self.searimg.hidden = NO;
        for (UILabel *sub in arr) {
            if ([sub.text isEqualToString:@"序号"]) {
                [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.equalTo(self.mas_top).offset(6);
                    make.left.equalTo(self.mas_left).offset(sub.centerX);
                    make.height.mas_equalTo(8);
                }];
            }
            if ([sub.text isEqualToString:@"终端编号（SN）"]) {
                [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.left.equalTo(self.mas_left).offset(sub.frame.origin.x);
                }];
            }
            if ([sub.text isEqualToString:@"查询"]) {
                [self.searimg mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.height.mas_equalTo(5);
                    make.width.mas_equalTo(9);
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.centerX.equalTo(self.mas_left).offset(sub.center.x);
                }];
            }
        }
    }
    if (_typeV == 5 && arr.count == 4) {//3、已达标
        self.posstatus = YES;
        self.number.hidden = NO;
        self.cashstatus.hidden = NO;
        self.vidtime.hidden = YES;
        self.searimg.hidden = NO;
        for (UILabel *sub in arr) {
            if ([sub.text isEqualToString:@"序号"]) {
                [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.equalTo(self.mas_top).offset(6);
                    make.left.equalTo(self.mas_left).offset(sub.centerX);
                    make.height.mas_equalTo(8);
                }];
            }
            if ([sub.text isEqualToString:@"终端编号（SN）"]) {
                [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.left.equalTo(self.mas_left).offset(sub.frame.origin.x);
                    make.height.mas_equalTo(20);
                }];
            }
            if ([sub.text isEqualToString:@"押金状态"]) {
                [self.cashstatus mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.centerX.equalTo(self.mas_left).offset(sub.center.x);
                }];
            }
            if ([sub.text isEqualToString:@"查询"]) {
                [self.searimg mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.height.mas_equalTo(5);
                    make.width.mas_equalTo(9);
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.centerX.equalTo(self.mas_left).offset(sub.center.x);
                }];
            }
        }
    }
    if (_typeV == 6 && arr.count == 3) {//4、已划拨
        self.posstatus = NO;
        self.number.hidden = NO;
        self.cashstatus.hidden = NO;
        self.vidtime.hidden = YES;
        self.searimg.hidden = YES;
        for (UILabel *sub in arr) {
            if ([sub.text isEqualToString:@"序号"]) {
                [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.equalTo(self.mas_top).offset(6);
                    make.left.equalTo(self.mas_left).offset(sub.centerX);
                    make.height.mas_equalTo(8);
                }];
            }
            if ([sub.text isEqualToString:@"终端编号（SN）"]) {
                [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.left.equalTo(self.mas_left).offset(sub.frame.origin.x);
                    make.height.mas_equalTo(20);
                }];
            }
            if ([sub.text isEqualToString:@"状态"]) {
                [self.cashstatus mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.equalTo(self.title.mas_centerY);
                    make.centerX.equalTo(self.mas_left).offset(sub.center.x);
                }];
            }
        }
    }
    if (_typeV == 7) {//5、可回拨
        self.posstatus = NO;
        self.number.hidden = NO;
        self.cashstatus.hidden = NO;
        self.vidtime.hidden = YES;
        self.searimg.hidden = NO;
        for (UIView *sub in arr) {
            if ([sub isKindOfClass:[UILabel class]]) {
                UILabel *sublab = (UILabel *)sub;
                if ([sublab.text isEqualToString:@"序号"]) {
                    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.top.equalTo(self.mas_top).offset(6);
                        make.left.equalTo(self.mas_left).offset(sub.centerX);
                        make.height.mas_equalTo(8);
                    }];
                }
                if ([sublab.text isEqualToString:@"终端编号（SN）"]) {
                    [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sublab.frame.origin.x);
                        make.height.mas_equalTo(20);
                    }];
                }
                if ([sublab.text isEqualToString:@"有效期"]) {
                    [self.cashstatus mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sub.centerX);
                    }];
                }
            }
            if ([sub isKindOfClass:[UIButton class]]) {
                UIButton *subbtn = (UIButton *)sub;
                if ([subbtn.titleLabel.text isEqualToString:@"批量"]) {
                    [self.searimg mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.height.mas_equalTo(14);
                        make.width.mas_equalTo(14);
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.mas_left).offset(subbtn.center.x);
                    }];
                }
            }
        }
    }
    if ((_typeV == 8 || _typeV == 10 || _typeV == 11) && arr.count == 6) {//6、我回拨的 历史记录
        self.posstatus = NO;
        self.number.hidden = NO;
        self.cashstatus.hidden = NO;
        self.vidtime.hidden = NO;
        self.searimg.hidden = YES;
        for (UIView *sub in arr) {
            if ([sub isKindOfClass:[UILabel class]]) {
                UILabel *sublab = (UILabel *)sub;
                if ([sublab.text isEqualToString:@"序号"]) {
                    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.top.equalTo(self.mas_top).offset(6);
                        make.left.equalTo(self.mas_left).offset(sub.centerX);
                        make.height.mas_equalTo(8);
                    }];
                }
                if ([sublab.text isEqualToString:@"终端编号（SN）"]) {
                    [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sublab.frame.origin.x);
                        make.height.mas_equalTo(20);
                    }];
                }
                if ([sublab.text isEqualToString:@"状态"]) {
                    [self.vidtime mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.mas_left).offset(sublab.center.x);
                    }];
                }
                if ([sublab.text isEqualToString:@"有效期"]) {
                    [self.cashstatus mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sub.centerX);
                    }];
                }
            }
        }
    }
    if (_typeV == 9 && arr.count == 6) {//7、别人回拨给我的
        self.posstatus = NO;
        self.number.hidden = NO;
        self.cashstatus.hidden = NO;
        self.vidtime.hidden = YES;
        self.searimg.hidden = NO;
        for (UIView *sub in arr) {
            if ([sub isKindOfClass:[UILabel class]]) {
                UILabel *sublab = (UILabel *)sub;
                if ([sublab.text isEqualToString:@"序号"]) {
                    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.top.equalTo(self.mas_top).offset(6);
                        make.left.equalTo(self.mas_left).offset(sub.centerX);
                        make.height.mas_equalTo(8);
                    }];
                }
                if ([sublab.text isEqualToString:@"终端编号（SN）"]) {
                    [_number mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sublab.frame.origin.x);
                        make.height.mas_equalTo(20);
                    }];
                }
                if ([sublab.text isEqualToString:@"有效期"]) {
                    [self.cashstatus mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.left.equalTo(self.mas_left).offset(sub.centerX);
                    }];
                }
            }
            if ([sub isKindOfClass:[UIButton class]]) {
                UIButton *subbtn = (UIButton *)sub;
                if ([subbtn.titleLabel.text isEqualToString:@"批量"]) {
                    [self.searimg mas_makeConstraints:^(MASConstraintMaker *make) {
                        make.height.mas_equalTo(14);
                        make.width.mas_equalTo(14);
                        make.centerY.equalTo(self.title.mas_centerY);
                        make.centerX.equalTo(self.mas_left).offset(subbtn.center.x);
                    }];
                }
            }
        }
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    if (self.posstatus == YES) {
        if (selected) {
            self.cellpush = !self.cellpush;
            if (self.cellPushBlock) self.cellPushBlock(self.cellpush);
        }
    }else{
        if (selected) {
            self.CellClik = !self.CellClik;
            if (self.CellClikBlock) self.CellClikBlock(self.CellClik);
        }
    }
    [super setSelected:selected animated:animated];
}

@end
